<%-- 
    Document   : Register
    Created on : Sep 29, 2012, 4:34:35 PM
    Author     : MinhThang
--%>

<%@page contentType="text/html" pageEncoding="UTF-8" errorPage="error.jsp" errorPage="error.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="description" content="website description" />
        <meta name="keywords" content="website keywords, website keywords" />
        <meta http-equiv="content-type" content="text/html; charset=windows-1252" />
        <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Tangerine&amp;v1#" />
        <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz" />
        <link rel="stylesheet" type="text/css" href="style/style.css" />

        <script src="jsDatePick.min.1.3.js"></script>
        <link rel="stylesheet" type="text/css" href="css/jsDatePick_ltr.min.css" />

        <script type="text/javascript">
            window.onload = function(){
                new JsDatePick({
                    useMode:2,
                    target:"date1",
                    isStripped:false,
                    selectedDate:{
                        year:1990,
                        month:1,
                        day:1
                    },
                    yearsRange: new Array(1945,2100),
                    imgPath:"img/",
                    dateFormat:"%d-%m-%Y",
                    weekStartDay:1,
                    limitToToday:true
                });
            };
        </script>

        <style>
            * {font-family:Arial, Helvetica, sans-serif;
               font-size:10pt;}
            </style>
            <title>Register</title>
            <script  type="text/javascript">   
                function check()
                {
                    var username = document.fregister.txtUserName.value;
                    var password = document.fregister.txtPassword.value;
                    var repassword = document.fregister.txtRePassword.value;
                    var fullname = document.fregister.txtFullName.value;
                    var birthday = document.fregister.txtBirthday.value;
                    var idcard = document.fregister.txtIDCard.value;
                    var email = document.fregister.txtEmail.value;
                    var mobile = document.fregister.txtMobile.value;
                    var address = document.fregister.txtAddress.value;
                    var image = document.fregister.fileUpLoad.value;
                    //var isValid = date.match(/^\d\d?\-\d\d?\-\d\d\d\d$/);

                    if(username =='' || username == null)
                    {
                        alert('Username is require');
                        document.fregister.txtUserName.focus();
                        return false;
                    }
                    else if(password =='' || password == null)
                    {
                        alert('Password is require');
                        document.fregister.txtPassword.focus();
                        return false;
                    }

                    else if(password.length < 6 ||password.length > 50 )
                    {
                        alert('Password must between 6 to 50 character');
                        document.fregister.txtPassword.select();
                        return false;
                    }

                    else if(repassword =='' || repassword == null)
                    {
                        alert('Repeat password is require');
                        document.fregister.txtRePassword.focus();
                        return false;
                    }

                    else if(repassword != password)
                    {
                        alert('Repeat password must be same password');
                        document.fregister.txtRePassword.select();
                        return false;
                    }

                    else if(fullname =='' || fullname == null)
                    {
                        alert('Full name is require');
                        document.fregister.txtFullName.focus();
                        return false;
                    }
                    else if(birthday =='' || birthday == null)
                    {
                        alert('Birthday is require');
                        document.fregister.txtBirthday.focus();
                        return false;
                    }

                    else if(idcard =='' || idcard == null)
                    {
                        alert('Id card is require');
                        document.fregister.txtIDCard.focus();
                        return false;
                    }

                    else if(!validateIDCard(idcard))
                    {
                        alert('Id card not valid');
                        document.fregister.txtIDCard.select();
                        return false;
                    }

                    else if(email =='' || email == null)
                    {
                        alert('Email is require');
                        document.fregister.txtEmail.focus();
                        return false;
                    }

                    else if(!validateEmail(email))
                    {
                        alert('Email not valid');
                        document.fregister.txtEmail.select();
                        return false;
                    }

                    else if(mobile =='' || mobile == null)
                    {
                        alert('Mobile is require');
                        document.fregister.txtMobile.focus();
                        return false;
                    }

                    else if(!validatemobile(mobile))
                    {
                        alert('Mobile is sai dinh dang');
                        alert(birthday);
                        document.fregister.txtMobile.select();
                        return false;
                    }

                    else if(address =='' || address == null)
                    {
                        alert('Address is require');
                        document.fregister.txtAddress.focus();
                        return false;
                    }
                    else if(image =='' || image == null)
                    {
                        alert('Image is require');
                        return false;
                    }
                    return true;
                }

                function validateEmail(email)
                {
                    var re = /\S+@\S+\.\S+/;
                    return re.test(email);
                }

                function validatemobile(mb) {
                    var re = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4,5})$/;
                    return re.test(mb);
                }

                function validateIDCard(idcard) {
                    var re = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{2,3})$/;
                    return re.test(idcard);
                }
            </script>
        </head>
        <body>
            <div>
                <div><%@include file="UserTemplate/Banner.jsp" %></div>
                <div id="site_content">
                    <form action="registerMember" onsubmit="return check();"  method="post"  name="fregister" id="form1" enctype="multipart/form-data">
                        <div id="content" >
                            <table  class="tableRegiter" style="width: 99.5%">
                            <tbody>
                                <tr >
                                    <td colspan="2" class="headerTable"><center><h3>Register</h3></center></td>
                                </tr>
                                <tr>
                                    <td  class="leftForm">User Name : </td>
                                    <td class="centerForm"><input id="textinput"  type="text" name="txtUserName" value="" /></td>
                                </tr>
                                <tr>
                                    <td class="leftForm">Password : </td>
                                    <td class="centerForm"><input id="textinput"  type="password" name="txtPassword" value="" /></td>
                                </tr>
                                <tr>
                                    <td class="leftForm">ReEnter Password : </td>
                                    <td class="centerForm"><input id="textinput"  type="password" name="txtRePassword" value="" /></td>
                                </tr>
                                <tr>
                                    <td class="leftForm">Full Name : </td>
                                    <td class="centerForm"><input type="text" id="textinput"  name="txtFullName" value=""/></td>
                                </tr>
                                <tr>
                                    <td class="leftForm">Gender : </td>
                                    <td class="centerForm">
                                        Male <input type="radio" name="gender" value="1" checked="checked" />
                                        Female <input type="radio" name="gender" value="0" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="leftForm">Birth day : </td>
                                    <td class="centerForm"><input type="text" style="height: 23px; width: 205px" readonly id="date1" name="txtBirthday" value="" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="leftForm">Identity card : </td>
                                    <td class="centerForm"><input type="text" id="textinput"  name="txtIDCard" value="" /> (XXX-XXX-XXX)</td>
                                </tr>
                                <tr>
                                    <td class="leftForm">Email : </td>
                                    <td class="centerForm"><input type="text" id="textinput"  name="txtEmail" value="" /> (abc@gmail.com)</td>
                                    <td class="leftForm" style="float: left"></td>
                                </tr>
                                <tr>
                                    <td class="leftForm">Mobile Phone : </td>
                                    <td class="centerForm"><input type="text" id="textinput"  name="txtMobile" value="" /> (09XX-XXX-XXX)</td>
                                </tr>
                                <tr>
                                    <td class="leftForm">Home Phone : </td>
                                    <td class="centerForm"><input type="text" id="textinput"  name="txtHomePhone" value="" /></td>
                                </tr>
                                <tr>
                                    <td class="leftForm">Address : </td>
                                    <td class="centerForm"><input type="text" id="textinput"  name="txtAddress" value="" /></td>
                                </tr>
                                <tr>
                                    <td class="leftForm">Image : </td>
                                    <td class="centerForm"><input id="textinput"  type="file" name="fileUpLoad" value="" style="color: red" class="errormessge" /></td>
                                </tr>
                                <tr>
                                    <td class="leftForm"> </td>
                                    <td class="centerForm">
                                        <input id="pagestatus" type="submit" value="Register Now" name="btRegister" />
                                        <input id="pagestatus" type="reset" value="Reset" name="bttReset" />
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </form>
                <div><%@include file="UserTemplate/MenuRight.jsp" %></div>
            </div>
            <div></div>
            <div><%@include file="UserTemplate/Footer.jsp" %></div>
        </div>

        <script type="text/javascript">
            var ng_config = {
                assests_dir: 'assets/'	// the path to the assets directory
            }
        </script>
    </body>
</html>
